1
2 using
System.Diagnostics;
3 using
System;
4 using
System.Xml.Linq;
5 using
System.Windows.Forms;
6 using
System.Collections;
7 using
System.Drawing;
8 using
Microsoft.VisualBasic;
9 using
System.Data;
10 using
System.Collections.Generic;
11 using
System.Linq;
12
13
14
15 namespace
Grading_System
16 {
17     
public partial class Form1
18     {
19         
public Form1()
20         {
21             InitializeComponent();
22             
23         
24         }
25         

26 #region
Default Instance
27         
28         
private static Form1 defaultInstance;
29         
30
31         
public static Form1 Default
32         {
33             
get
34             {
35                 
if (defaultInstance == null)
36                 {
37                     defaultInstance =
new Form1();
38                     defaultInstance.FormClosed +=
new FormClosedEventHandler(defaultInstance_FormClosed);
39                 }
40                 
41                 
return defaultInstance;
42             }
43         }
44         
45         
static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e)
46         {
47             defaultInstance =
null;
48         }
49         

50 #endregion

51         
52         DataSet dsgrade;
53         DataSet newgrade =
new DataSet();
54         
int inc;
55         
56         
int MaxRows;
57         
58         
public void Button1_Click(System.Object sender, System.EventArgs e)
59         {
60             
int a = default(int);
61             
decimal b = new decimal();
62             
63             
if (Information.IsNumeric(TextBox3.Text))
64             {
65                 
if (int.Parse(TextBox3.Text) <= 20 )
66                 {
67                     a = (
int) ((double.Parse(TextBox3.Text) * 100) / 20);
68                     TextBox4.Text = a.ToString();
69                     b = (
decimal) (a * 0.1);
70                     TextBox5.Text = b.ToString();
71                 }
72                 
else
73                 {
74                     MessageBox.Show(
"Please Enter value equal to 20 and below!");
75                 }
76             }
77             
if (Information.IsNumeric(TextBox6.Text))
78             {
79                 
80                 
if (int.Parse(TextBox6.Text) <= 50 )
81                 {
82                     
int c = default(int);
83                     
decimal d = new decimal();
84                     c = (
int) ((double.Parse(TextBox6.Text) * 100) / 50);
85                     TextBox7.Text = c.ToString();
86                     d = (
decimal) (c * 0.1);
87                     TextBox8.Text = d.ToString();
88                     
89                 }
90                 
else
91                 {
92                     MessageBox.Show(
"Please Enter value equal to 50 and below!");
93                     
94                     
95                 }
96             }
97             
98             
if (Information.IsNumeric(TextBox9.Text))
99             {
100                 
if (int.Parse(TextBox9.Text) <= 50 )
101                 {
102                     
int g = default(int);
103                     
decimal f = new decimal();
104                     g = (
int) ((double.Parse(TextBox9.Text) * 100) / 50);
105                     TextBox10.Text = g.ToString();
106                     f = (
decimal) (g * 0.2);
107                     TextBox11.Text = f.ToString();
108                     
109                 }
110                 
else
111                 {
112                     MessageBox.Show(
"Please Enter value equal to 50 and below!");
113                     
114                     
115                 }
116             }
117             
if (Information.IsNumeric(TextBox12.Text))
118             {
119                 
if (int.Parse(TextBox12.Text) <= 100 )
120                 {
121                     
int g = default(int);
122                     
decimal f = new decimal();
123                     g = (
int) ((double.Parse(TextBox12.Text) * 100) / 100);
124                     TextBox13.Text = g.ToString();
125                     f = (
decimal) (g * 0.3);
126                     TextBox14.Text = f.ToString();
127                     
128                 }
129                 
else
130                 {
131                     MessageBox.Show(
"Please Enter value equal to 100 and below!");
132                     
133                     
134                 }
135             }
136             
137             
if (Information.IsNumeric(TextBox15.Text))
138             {
139                 
if (int.Parse(TextBox15.Text) <= 100 )
140                 {
141                     
int j = default(int);
142                     
decimal f1 = new decimal();
143                     j = (
int) ((double.Parse(TextBox15.Text) * 100) / 100);
144                     TextBox16.Text = j.ToString();
145                     f1 = (
decimal) (j * 0.3);
146                     TextBox17.Text = f1.ToString();
147                     
148                 }
149                 
else
150                 {
151                     MessageBox.Show(
"Please Enter value equal to 100 and below!");
152                     
153                     
154                 }
155             }
156             
157             
decimal adal = new decimal();
158             adal = (
decimal) (Conversion.Val(TextBox5.Text) + Conversion.Val(TextBox8.Text) + Conversion.Val(TextBox11.Text) + Conversion.Val(TextBox14.Text) + Conversion.Val(TextBox17.Text));
159             
160             TextBox18.Text = adal.ToString();
161             
162             
if (Conversion.Val(TextBox18.Text) <= 74)
163             {
164                 
165                 TextBox19.Text =
"Failed";
166                 TextBox19.ForeColor = Color.Red;
167             }
168             
else
169             {
170                 TextBox19.Text =
"Passed";
171                 TextBox19.ForeColor = Color.Black;
172                 
173                 
174             }
175             
176             
177         }
178         
179         
public void Button2_Click(System.Object sender, System.EventArgs e)
180         {
181             
this.Close();
182             
183         }
184         
185         
public void Button3_Click(System.Object sender, System.EventArgs e)
186         {
187             
188             TextBox1.Text =
"";
189             TextBox12.Text =
"";
190             TextBox3.Text =
"";
191             TextBox4.Text =
"";
192             TextBox5.Text =
"";
193             TextBox6.Text =
"";
194             TextBox7.Text =
"";
195             TextBox8.Text =
"";
196             TextBox9.Text =
"";
197             TextBox10.Text =
"";
198             TextBox11.Text =
"";
199             TextBox12.Text =
"";
200             TextBox13.Text =
"";
201             TextBox14.Text =
"";
202             TextBox15.Text =
"";
203             TextBox16.Text =
"";
204             TextBox17.Text =
"";
205             TextBox18.Text =
"";
206             TextBox19.Text =
"";
207             
208             
209         }
210         

211 #region
my data
212         
protected override void OnLoad(System.EventArgs e)
213         {
214             
base.OnLoad(e);
215             
string sPath = Application.ExecutablePath;
216             sPath = System.IO.Path.GetDirectoryName(sPath);
217             
218             
if (sPath.EndsWith("\\bin"))
219             {
220                 sPath = sPath.Substring(
0, sPath.Length - 4);
221             }
222             
223             gradeclass.DataModule =
new gradeclass(sPath);
224             
225         }

226 #endregion

227         
228         
public void Button5_Click(System.Object sender, System.EventArgs e)
229         {
230             newgrade = gradeclass.DataModule.GetLoad();
231             DataGridView1.DataSource = newgrade;
232             DataGridView1.DataMember =
"grade1";
233             
234         }
235         
236         
public void Button4_Click(System.Object sender, System.EventArgs e)
237         {
238             
239             
string strmessage = default(string);
240             DialogResult dgrResult;
241             
242             strmessage =
"Are you sure you want to save data?";
243             dgrResult = MessageBox.Show(strmessage,
"Save data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
244             
245             
246             
if (dgrResult == System.Windows.Forms.DialogResult.Yes)
247             {
248                 
249                 newgrade = gradeclass.DataModule.SaveItem();
250             }
251             
252         }
253         
254         
public void NavRecords()
255         {
256             
257             STUDID.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][1]);
258             TextBox1.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][2]);
259             TextBox2.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][3]);
260             TextBox3.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][4]);
261             TextBox4.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][5]);
262             TextBox5.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][6]);
263             TextBox6.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][7]);
264             TextBox7.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][8]);
265             TextBox8.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][9]);
266             TextBox9.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][10]);
267             TextBox10.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][11]);
268             TextBox11.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][12]);
269             TextBox12.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][13]);
270             TextBox13.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][14]);
271             TextBox14.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][15]);
272             TextBox15.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][16]);
273             TextBox16.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][17]);
274             TextBox17.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][18]);
275             TextBox18.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][19]);
276             TextBox19.Text = (
string) (dsgrade.Tables["grade1"].Rows[inc][20]);
277             
278         }
279         
280         
281         
282         
public void FRST_Click(System.Object sender, System.EventArgs e)
283         {
284             dsgrade = gradeclass.DataModule.navigate();
285             
if (inc != 0)
286             {
287                 inc =
0;
288                 NavRecords();
289                 MessageBox.Show(
"First Record");
290             }
291         }
292         
293         
public void PREV_Click(System.Object sender, System.EventArgs e)
294         {
295             
296             dsgrade = gradeclass.DataModule.navigate();
297             
if (inc > 0)
298             {
299                 inc--;
300                 NavRecords();
301             }
302             
else if (inc == -1)
303             {
304                 MessageBox.Show(
"No Records Yet");
305             }
306             
else if (inc == 0)
307             {
308                 MessageBox.Show(
"First Record");
309             }
310             
311             
312         }
313         
314         
public void LAST_Click(System.Object sender, System.EventArgs e)
315         {
316             dsgrade = gradeclass.DataModule.navigate();
317             MaxRows = dsgrade.Tables[
"grade1"].Rows.Count;
318             
if (inc != MaxRows)
319             {
320                 inc = MaxRows -
1;
321                 NavRecords();
322             }
323             
else
324             {
325                 MessageBox.Show(
"Last Record");
326             }
327         }
328         
329         
public void NXT_Click(System.Object sender, System.EventArgs e)
330         {
331             dsgrade = gradeclass.DataModule.navigate();
332             
try
333             {
334                 
if (inc != MaxRows - 1)
335                 {
336                     inc++;
337                     NavRecords();
338                 }
339             }
340             
catch (Exception)
341             {
342                 MessageBox.Show(
"No More Rows");
343             }
344         }
345         DataSet dsupdate;
346         
347         
public void Button6_Click(System.Object sender, System.EventArgs e)
348         {
349             
350             TextBox1.Text = DataGridView1.CurrentRow.Cells[
1].Value.ToString();
351             TextBox2.Text = DataGridView1.CurrentRow.Cells[
2].Value.ToString();
352             TextBox3.Text = DataGridView1.CurrentRow.Cells[
3].Value.ToString();
353             TextBox4.Text = DataGridView1.CurrentRow.Cells[
4].Value.ToString();
354             TextBox5.Text = DataGridView1.CurrentRow.Cells[
5].Value.ToString();
355             TextBox6.Text = DataGridView1.CurrentRow.Cells[
6].Value.ToString();
356             TextBox7.Text = DataGridView1.CurrentRow.Cells[
7].Value.ToString();
357             TextBox8.Text = DataGridView1.CurrentRow.Cells[
8].Value.ToString();
358             TextBox9.Text = DataGridView1.CurrentRow.Cells[
9].Value.ToString();
359             TextBox10.Text = DataGridView1.CurrentRow.Cells[
10].Value.ToString();
360             TextBox11.Text = DataGridView1.CurrentRow.Cells[
11].Value.ToString();
361             TextBox12.Text = DataGridView1.CurrentRow.Cells[
12].Value.ToString();
362             TextBox13.Text = DataGridView1.CurrentRow.Cells[
13].Value.ToString();
363             TextBox14.Text = DataGridView1.CurrentRow.Cells[
14].Value.ToString();
364             TextBox15.Text = DataGridView1.CurrentRow.Cells[
15].Value.ToString();
365             TextBox16.Text = DataGridView1.CurrentRow.Cells[
16].Value.ToString();
366             TextBox17.Text = DataGridView1.CurrentRow.Cells[
17].Value.ToString();
367             TextBox18.Text = DataGridView1.CurrentRow.Cells[
18].Value.ToString();
368             TextBox19.Text = DataGridView1.CurrentRow.Cells[
19].Value.ToString();
369             STUDID.Text = DataGridView1.CurrentRow.Cells[
0].Value.ToString();
370             
371         }
372         
373         
public void Button11_Click(System.Object sender, System.EventArgs e)
374         {
375             
string strmessage = default(string);
376             DialogResult dgrResult;
377             
378             strmessage =
"Are you sure you want to Delete this record?";
379             dgrResult = MessageBox.Show(strmessage,
"Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
380             
381             
382             
if (dgrResult == System.Windows.Forms.DialogResult.Yes)
383             {
384                 
385                 dsgrade = gradeclass.DataModule.deldata();
386                 
387             }
388             
389             
390             
391         }
392         
393         
public void Button7_Click(System.Object sender, System.EventArgs e)
394         {
395             dsgrade = gradeclass.DataModule.updtedata();
396         }
397         
public void DataGridView1_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
398         {
399             TextBox1.Text = DataGridView1.Rows[e.RowIndex].Cells[
1].Value.ToString();
400             TextBox2.Text = DataGridView1.Rows[e.RowIndex].Cells[
2].Value.ToString();
401             TextBox3.Text = DataGridView1.Rows[e.RowIndex].Cells[
3].Value.ToString();
402             TextBox4.Text = DataGridView1.Rows[e.RowIndex].Cells[
4].Value.ToString();
403             TextBox5.Text = DataGridView1.Rows[e.RowIndex].Cells[
5].Value.ToString();
404             TextBox6.Text = DataGridView1.Rows[e.RowIndex].Cells[
6].Value.ToString();
405             TextBox7.Text = DataGridView1.Rows[e.RowIndex].Cells[
7].Value.ToString();
406             TextBox8.Text = DataGridView1.Rows[e.RowIndex].Cells[
8].Value.ToString();
407             TextBox9.Text = DataGridView1.Rows[e.RowIndex].Cells[
9].Value.ToString();
408             TextBox10.Text = DataGridView1.Rows[e.RowIndex].Cells[
10].Value.ToString();
409             TextBox11.Text = DataGridView1.Rows[e.RowIndex].Cells[
11].Value.ToString();
410             TextBox12.Text = DataGridView1.Rows[e.RowIndex].Cells[
12].Value.ToString();
411             TextBox13.Text = DataGridView1.Rows[e.RowIndex].Cells[
13].Value.ToString();
412             TextBox14.Text = DataGridView1.Rows[e.RowIndex].Cells[
14].Value.ToString();
413             TextBox15.Text = DataGridView1.Rows[e.RowIndex].Cells[
15].Value.ToString();
414             TextBox16.Text = DataGridView1.Rows[e.RowIndex].Cells[
16].Value.ToString();
415             TextBox17.Text = DataGridView1.Rows[e.RowIndex].Cells[
17].Value.ToString();
416             TextBox18.Text = DataGridView1.Rows[e.RowIndex].Cells[
18].Value.ToString();
417             TextBox19.Text = DataGridView1.Rows[e.RowIndex].Cells[
19].Value.ToString();
418             STUDID.Text = DataGridView1.Rows[e.RowIndex].Cells[
0].Value.ToString();
419             
420             
421         }
422     }
423     
424 }



Hệ thống thông tin sinh viên trong C# 5.181 lượt xem

Gõ tìm kiếm nhanh...